package com.hnevc.xiaoming.huituactivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

import com.hnevc.xiaoming.R;

public class TranslateActivity extends AppCompatActivity implements View.OnClickListener {

    private ImageView anim_img;
    private Button btn_alpha;
    private Button btn_rotate;
    private Button btn_scale;
    private Button btn_translate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_translate);
        initView();


    }

    @Override
    protected void onDestroy() {
        super.onDestroy();


    }

    private void initView() {
        anim_img = (ImageView) findViewById(R.id.anim_img);
        btn_alpha = (Button) findViewById(R.id.btn_alpha);
        btn_rotate = (Button) findViewById(R.id.btn_rotate);
        btn_scale = (Button) findViewById(R.id.btn_scale);
        btn_translate = (Button) findViewById(R.id.btn_translate);

        btn_alpha.setOnClickListener(this);
        btn_rotate.setOnClickListener(this);
        btn_scale.setOnClickListener(this);
        btn_translate.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_alpha:
//                Animation alpha = AnimationUtils.loadAnimation(this,R.anim.alpha_animation);
//                anim_img.startAnimation(alpha);
                startActivity(new Intent(TranslateActivity.this,ToActivity.class));

                overridePendingTransition(R.anim.alpha_animation,R.anim.translate_animation);
                break;
            case R.id.btn_rotate:
                Animation rotate = AnimationUtils.loadAnimation(this,R.anim.rotate_animation);
                anim_img.startAnimation(rotate);
                break;
            case R.id.btn_scale:
                Animation scale = AnimationUtils.loadAnimation(this,R.anim.scale_animation);
                anim_img.startAnimation(scale);
                break;
            case R.id.btn_translate:
                Animation translate = AnimationUtils.loadAnimation(this,R.anim.translate_animation);
                anim_img.startAnimation(translate);
                break;
        }
    }
}